package com.xmy.cultivate.service;

import com.xmy.cultivate.entity.BookStudent;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmy.cultivate.entity.request.BookGrantRs;
import com.xmy.cultivate.util.Result;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 订购学生 服务类
 * </p>
 *
 * @author hpiggy
 * @since 2025-01-04
 */
public interface IBookStudentService extends IService<BookStudent> {

    Result grantBookForStudent(BookStudent bookStudentParam, String ossImageUrl);

    Long getNeedGrantCount(Integer yearPart,
                           Integer quarterNum,
                           Long schoolId,
                           Long subjectsId,
                           Long teacherId,
                           Integer status);

    /**
     * 按老师发放
     *
     * @param yearPart
     * @param quarterNum
     * @param ossImageUrl
     * @param adminId
     * @param bookGrantRs
     * @return
     */
    @Transactional
    boolean bookGrant(Integer yearPart,
                      Integer quarterNum,
                      String ossImageUrl,
                      Long adminId,
                      BookGrantRs bookGrantRs
    );

    /**
     * 按学生发放
     *
     * @param yearPart
     * @param quarterNum
     * @param ossImageUrl
     * @param adminId
     * @param bookGrantRs
     * @return
     */
    @Transactional
    boolean bookGrantStudent(Integer yearPart,
                             Integer quarterNum,
                             String ossImageUrl,
                             Long adminId,
                             BookGrantRs bookGrantRs
    );

    Long getNeedGrantPaperCount(Integer yearPart,
                                Integer quarterNum,
                                Long schoolId,
                                Long subjectsId,
                                Long teacherId,
                                Integer status);

    boolean bookGrantPaper(Integer yearPart,
                           Integer quarterNum,
                           Long schoolId,
                           Long subjectsId,
                           Long teacherId,
                           Integer grantType,
                           String imgOss,
                           Long adminId);

    /**
     * 教师可发放
     *
     * @param yearPart
     * @param quarterNum
     * @param schoolId
     * @param subjectsId
     * @param teacherId
     * @param status
     * @param type
     * @return
     */
    List<BookStudent> getDistributable(Integer yearPart,
                                       Integer quarterNum,
                                       Long schoolId,
                                       Long subjectsId,
                                       Long teacherId,
                                       Integer status,
                                       Integer type,
                                       String bookTextType,
                                       Integer isDetails,
                                       String studentName,
                                       String gradeId,
                                       String bookTextId,
                                       Long classTypeId,
                                       String yearClassId,
                                       Integer lessonNum
    );

    /**
     * 学生可发放
     *
     * @param yearPart
     * @param quarterNum
     * @param schoolId
     * @param subjectsId
     * @param studentId
     * @param status
     * @return
     */
    List<BookStudent> getDistributableStudent(Integer yearPart, Integer quarterNum, Long schoolId, Long subjectsId, Long studentId, Integer status, Integer bookTextType);
}
